package com.xyhy.starter.mfx.listener;

import com.mybatisflex.annotation.UpdateListener;
import com.xyhy.core.utils.spring.SpringContextUtil;
import com.xyhy.starter.mfx.entity.IAuditable;

import java.time.LocalDateTime;

public class MfxObjectUpdateListener implements UpdateListener {
  @Override
  public void onUpdate(Object entity) {
    if (!(entity instanceof IAuditable)) return;
    IAuditable object = (IAuditable) entity;

    object.setUpdateBy(SpringContextUtil.getUserId());
    object.setUpdateTime(LocalDateTime.now());
  }

}
